package indi.zhifa.recipe.bailan.framework.common.util.xml;


import indi.zhifa.recipe.bailan.framework.common.util.LocalDateTimeUtil;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;

import java.time.LocalDateTime;

/**
 * @author 芝法酱
 */
public class JaxbLocalDateAdapter extends XmlAdapter<String, LocalDateTime> {


    @Override
    public LocalDateTime unmarshal(String v) throws Exception {
        if (v == null) {
            return null;
        }
        return LocalDateTimeUtil.parse(v);
    }

    @Override
    public String marshal(LocalDateTime v) throws Exception {
        return LocalDateTimeUtil.toString(v);
    }

}
